<?php

$app->post('/test/image', 'test_uploadImages');

function test_uploadImages() {
	$data = $_POST['image'];
	$format = $_POST['format'];
	echo $data;

	$data = base64_decode($data);
	$image = imagecreatefromstring($data);

	if ($format == "png") {
    		imagepng($image, "test.png");
	} else if ($format == "jpg") {
    		imagejpeg($image, "test.jpg");
	} else if ($format == "gif") {
    		imagegif($image, "test.gif");
	} else {
		echo "Unsupported format: $format";
	}
}
?>
